export function genURL({ name, path, version = "" }) {
    if (version) version = "@" + version;

    return `https://cdn.jsdelivr.net/npm/${name}${version}${path}`;
}
export function injectScript(url) {
    return new Promise((resolve, reject) => {
        const preview = Object.keys(window);
        let script = document.createElement("script");
        script.src = url;
        script.onload = () => {
            const newVar = Object.keys(window).filter(
                (i) => !preview.includes(i)
            );

            resolve(newVar);
        };
        script.onerror = () => reject();
        document.body.appendChild(script);
    });
}
